const state = {
    deviceAlarms:[]
}

const getters = {
    // getDeviceAlarms(state) {
    //     return state.deviceAlarms;
    // }
    getDeviceAlarms: state => state.deviceAlarms

}

const mutations = {
    insertDeviceAlarm: (state, item) => {state.deviceAlarms.push(item)},
    // 一次性向数组中添加多个元素，传入的参数为一个json数组
    insertDeviceAlarms: (state, items) => {
        for (var i=0; i<items.length; i++) {
            state.deviceAlarms.push(items[i])
        }
    }
}

const actions = {
    insertDeviceAlarm: (state, item) => {state.commit('insertDeviceAlarm', item)},
    insertDeviceAlarms: (state, items) => {state.commit('insertDeviceAlarms', items)}
}

export default {
    state, getters, mutations, actions
}